﻿using System.Collections;

namespace UI
{
    public static class UIAnimationHandlers
    {
        public static IEnumerator PlayOpenAnimation(UIElement ui)
        {
            if (ui == null) yield break;
            var animation = ui.GetComponent<IUIAnimation>();
            ui.gameObject.SetActive(true);
            if (animation != null)
            {
                yield return animation.PlayShow();
            }
        }

        public static IEnumerator PlayCloseAnimation(UIElement ui)
        {
            if (ui == null) yield break;
            var animation = ui.GetComponent<IUIAnimation>();
            if (animation != null)
            {
                yield return animation.PlayHide();
            }
            ui.gameObject.SetActive(false);
        }
    }


}
